﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using OnlineMovieTicket.Services.IServices;
using OnlineMovieTicket.Services.Services;
using OnlineMovieTicket.Model;
using OnlineMovieTicket.ViewModels;
using System.Data.SqlClient;

namespace OnlineMovieTicket.Controllers
{
    public class ReportController : Controller
    {
        //
        // GET: /BestMovies/
        ITopTenMoivesService topTenMovieSrv;

           public ReportController()
        {
             topTenMovieSrv = new TopTenMoviesService();
        }

        public ReportController(ITopTenMoivesService serv)
        {
            topTenMovieSrv=serv;
        }

        public ActionResult ReportFilter()
        {
            ITopTenMoivesService movieSrv = new TopTenMoviesService();
            MoviesStatisticsSearchModel s = new MoviesStatisticsSearchModel();
            return View(s);
        }

        [HttpPost]
        public ActionResult ReportFilter(MoviesStatisticsSearchModel s)
        {
            
            //IMovieAssignmentService movieAssignSrv = new MovieAssignmentService();
            IList<Model.TopTenMoviesDetail> data= new List<Model.TopTenMoviesDetail>();
            if (s.FilterOption == 0)
            {
                 data = topTenMovieSrv.GetTopTenMoviesByRating(s.StartDate, s.EndDate);
                 if (Request.IsAjaxRequest())
                    return View("MoviesStatisticsByRating", data);
               
            }
            else
            {
              data = topTenMovieSrv.GetTopTenMoviesByTicket(s.StartDate,s.EndDate);
                 if (Request.IsAjaxRequest())
                    return View("MoviesStatisticsByTicket", data);
            }
            return View(data);
            }
            
        }

      
    }

